package com.tepth.vehiclemaintenance.mvp.work.content;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;

import com.tepth.vehiclemaintenance.R;


/**
 * Created by zhangyu on 2017/4/13.
 */

public class RemarkDialog extends Dialog {
    public interface OnConfirmListener {
        void onConfirm(String remark);
    }

    public RemarkDialog(Context context, String remark, final OnConfirmListener listener) {
        super(context, R.style.blurDialog);
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.view_dialog_remark, null);
        setContentView(view);
        final EditText editText = (EditText) view.findViewById(R.id.et_remark);
        if (remark != null) {
            editText.setText(remark);
            editText.setSelection(remark.length());
        }
        view.findViewById(R.id.btn_sure).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String remark = editText.getText().toString().trim();
                listener.onConfirm(remark);
                dismiss();
            }
        });
        view.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}
